import { getWindows } from '@nut-tree/nut-js';

const windows = await getWindows();

for (const currentWindow of windows) {
  try {
    // const windowHandle = await currentWindow.getHandle();
    // console.log('windowHandle: ', windowHandle);
    const windowTitle = await currentWindow.getTitle();
    console.log('windowTitle: ', windowTitle);
    const windowRegion = await currentWindow.getRegion();
    console.log('windowRegion: ', windowRegion);
    console.log('windowHandle: ', currentWindow.windowHandle);
    if (windowTitle.includes('微信')) {
      currentWindow.focus();
    }
  } catch (e) {
    console.error('获取窗口信息失败:', e.message);
  }
}